﻿using System;
using System.Threading.Tasks;
using Windows.UI.Xaml;

// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236

namespace com.IronOne.BoardPACWinApp.View.UserControl
{
    public sealed partial class MeetingNoteDialogUserControl
    {
        public delegate Task GetMeetingNoteDel(string comment, Object sender);

        public MeetingNoteDialogUserControl()
        {
            InitializeComponent();
        }

        public MeetingNoteDialogUserControl(string addedMeetingNote) //, AppBar tAppBar, AppBar bAppBar
        {
            InitializeComponent();

            TxbComment.Text = "";
            if (!String.IsNullOrEmpty(addedMeetingNote))
                TxbComment.Text = addedMeetingNote.Replace("<br/>", "\r\n");

            //topAppBar = tAppBar;
            //bottomAppBar = bAppBar;
        }

        public static event GetMeetingNoteDel GetMeetingNoteEvt;

        public void ShowPopup()
        {
            MRect1.Height = Window.Current.Bounds.Height;
            MRect1.Width = Window.Current.Bounds.Width;

            PopStk.Width = Window.Current.Bounds.Width / 2;
            PopStk.Height = Window.Current.Bounds.Height * 0.30;
            TxbComment.Height = PopStk.Height / 2.5;
            TxbComment.Focus(FocusState.Programmatic);

            ContentPopup.IsOpen = true;
            ContentPopup.IsLightDismissEnabled = false;

            //topAppBar.IsEnabled = false;
            //bottomAppBar.IsEnabled = false;
        }

        public void ClosePopup()
        {
            ContentPopup.IsOpen = false;
        }

        private async void Done_Click(object sender, RoutedEventArgs e)
        {
            if (GetMeetingNoteEvt != null) await GetMeetingNoteEvt(TxbComment.Text, sender);
            ClosePopup();
        }
    }
}